package com.example.controller;

import com.example.common.Result;
import com.example.entity.ExamQuestionPack;
import com.example.service.ExamPaperService;
import com.example.service.ExamQuestionPackService;
import com.example.service.impl.ExamPaperServiceImpl;
import com.example.vo.ExamPaperPackageSummaryVO;
import com.example.vo.ExamPaperPackageDetailVO;
import com.example.utils.ExamPaperPackageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@RestController
@RequestMapping("/examPackages")
public class ExamPaperPackageController {

    //调用实现类
    @Autowired
    ExamQuestionPackService examQuestionPackService;

    // 获取所有试题包列表
    @GetMapping
    public  Result<List<ExamPaperPackageSummaryVO>> getAllExamPaperPackages() {

        // 获取所有的 试题包中的试题数量
        List<ExamPaperPackageSummaryVO> summary = examQuestionPackService.getAllExamPaperPackagesSummary();

        return Result.success(summary);
    }



    //  获取试题包详数据
    @GetMapping("detail")
    public Result<ExamPaperPackageDetailVO>  getExamPaperPackageDetail(@RequestParam("packageName") String packageName) {
            // 查询数据库获取试题包详细信息
        ExamPaperPackageDetailVO examPaperPackageDetail = examQuestionPackService.getExamPaperPackageDetail(packageName);

        return Result.success(examPaperPackageDetail);

        }

}
